﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace CommunitySystemModel
{
    [Serializable]
    [DataContract]
    public class Emp_FamilyRelationModel
    {
        private int _ID;
        [DataMember]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

        private int _EmpBasicID;
        [DataMember]
        public int EmpBasicID
        {
            get { return _EmpBasicID; }
            set { _EmpBasicID = value; }
        }

        private string _Name = string.Empty;
        [DataMember]
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        private string _Appellation = string.Empty;
        [DataMember]
        public string Appellation
        {
            get { return _Appellation; }
            set { _Appellation = value; }
        }

        private string _Unit = string.Empty;
        [DataMember]
        public string Unit
        {
            get { return _Unit; }
            set { _Unit = value; }
        }

        private string _Duty = string.Empty;
        [DataMember]
        public string Duty
        {
            get { return _Duty; }
            set { _Duty = value; }
        }

        private string _Political = string.Empty;
        [DataMember]
        public string Political
        {
            get { return _Political; }
            set { _Political = value; }
        }

        private DateTime? _Birthday = null;
        [DataMember]
        public DateTime? Birthday
        {
            get { return _Birthday; }
            set { _Birthday = value; }
        }

        private string _EmpName = string.Empty;
        [DataMember]
        public string EmpName
        {
            get { return _EmpName; }
            set { _EmpName = value; }
        }

        private string _EmpNo = string.Empty;
        [DataMember]
        public string EmpNo
        {
            get { return _EmpNo; }
            set { _EmpNo = value; }
        }

        public static Emp_FamilyRelationModel FillEntity(DataRow dr)
        {
            Emp_FamilyRelationModel right = new Emp_FamilyRelationModel();
            right.ID = (int)dr["ID"];
            right.EmpBasicID = (int)dr["EmpBasicID"];
            right.Name = dr["Name"] as string;
            right.Appellation = dr["Appellation"] as string;
            right.Unit = dr["Unit"] as string;
            right.Duty = dr["Duty"] as string;
            right.Political = dr["Political"] as string;
            right.EmpName = dr["EmpName"] as string;
            right.EmpNo = dr["EmpNo"] as string;
            right.Birthday = (string.IsNullOrEmpty(dr["Birthday"].ToString()) || dr["Birthday"].ToString() == "1900/1/1 0:00:00") ? null : (DateTime?)dr["Birthday"];
            return right;
        }
    }
}
